from flask import Flask, render_template

from .admin_bp import admin_bp
from .article_bp import article_bp
from .echarts_bp import echarts_bp
from .index_bp import index_bp
from .user_bp import user_bp


def register_blueprint(app: Flask):
    # 用来注册视图的函数
    app.register_blueprint(index_bp)
    app.register_blueprint(article_bp)
    app.register_blueprint(user_bp)
    app.register_blueprint(admin_bp)
    app.register_blueprint(echarts_bp)

    @app.errorhandler(403)
    def error_view(e):
        return render_template("admin/error/403.html")
